<template>
  <p-table
    class="table-list-container"
    row-key="id"
    :columns="columns"
    :scroll="{ x: 1400, y: 300 }"
    bordered
    :data-source="dataSource"
    :pagination="paginationMixin"
    :row-selection="rowSelectionMixin"
    v-bind="$attrs"
    v-on="$listeners"
  >
    <a
      slot="serialNumber"
      slot-scope="text, record"
      @click="$emit('number-click', record)"
    >
      {{ text }}
    </a>
  </p-table>
</template>

<script>
export default {
  data() {
    return {};
  },
  computed: {
    stateOptions() {
      return this.$store.state.dictionary.dict['leads_create_status'] || {};
    },
    appOptions() {
      return this.$store.state.dictionary.dict['application'] || {};
    },
    columns() {
      const columns = [
        {
          align: 'center',
          title: '序号',
          width: 60,
          customRender(t, r, index) {
            return parseInt(index) + 1;
          },
        },
        {
          align: 'center',
          title: '线索编号',
          dataIndex: 'leadsNo',
          scopedSlots: { customRender: 'clueNumber' },
        },
        {
          align: 'center',
          title: '线索名称',
          dataIndex: 'leadsName',
        },
        {
          align: 'center',
          title: '线索状态',
          dataIndex: 'currStatus',
          customRender: text => this.stateOptions[text],
        },
        {
          align: 'center',
          title: '销售组织',
          dataIndex: 'salesOrgCode',
        },
        {
          align: 'center',
          title: '应用别',
          dataIndex: 'appCategory',
          customRender: text => this.appOptions[text],
        },
        {
          align: 'center',
          title: '销售组',
          dataIndex: 'salesGroupCode',
        },
        {
          align: 'center',
          title: 'KAPM组',
          dataIndex: 'pmGroupCode',
        },
        {
          align: 'center',
          title: '创建人',
          dataIndex: 'createUserName',
        },
        {
          align: 'center',
          title: '创建时间',
          dataIndex: 'createTime',
        },
      ];
      return columns;
    },
  },
};
</script>

<style lang="less" scoped>
.table-list-container {
  margin-top: 20px;
}
/deep/ .poros-table-thead > tr > th {
  background-color: #d1ebf7;
}
</style>
